package yjj.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import yjj.system.entity.UserRole;
import yjj.system.mapper.UserRoleMapper;
import yjj.system.service.UserRoleService;

import java.util.List;

@Service
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> implements UserRoleService {
    @Override
    public String getRoleByUserId(String userId) {
        LambdaQueryWrapper<UserRole> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(UserRole::getUserId, userId);
        List<UserRole> list = this.list(queryWrapper);
        if (!list.isEmpty()) {
            return list.get(0).getRoleId();
        }
        return null;

    }
}
